<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>模板</title>
  </head>
  <body>
    <!-- 准备好一个容器 -->
    <div id="test"></div>

    <!-- 引入react核心库 -->
    <script type="text/javascript" src="../js/react.development.js"></script>
    <!-- 引入react-dom，用于支持react操作DOM -->
    <script
      type="text/javascript"
      src="../js/react-dom.development.js"
    ></script>
    <!-- 引入babel，用于将jsx转换成js -->
    <script type="text/javascript" src="../js/babel.min.js"></script>
    <script type="text/babel">
      //创建组件,现用现取就是非受控组件
      class Login extends React.Component {
        handleSubmit = (event) => {
          event.preventDefault();
          const { usernameInput, passwordInput } = this;
          alert(
            `username:${usernameInput.value}---password:${passwordInput.value}`
          );
        };

        render() {
          return (
            <form action="#" onSubmit={this.handleSubmit}>
              账号：
              <input
                ref={(currentNode) => (this.usernameInput = currentNode)}
                type="text"
                name="username"
              />
              密码：
              <input
                ref={(currentNode) => (this.passwordInput = currentNode)}
                type="password"
                name="passsword"
              />
              <button>登录</button>
              {/*<input type="submit" value="提交表单" />*/}
            </form>
          );
        }
      }

      ReactDOM.render(<Login />, document.querySelector("#test"));
    </script>
  </body>
</html>
